#include <iostream>
using namespace std;

class Complex {
public:
	Complex (int r, int i):m_r(r),m_i(i) {}
	//<< 插入操作符
	friend ostream& operator<< (ostream& os, const Complex& c) {
		os << c.m_r << '+' << c.m_i << 'i';
		return os;
	}
	//>>提取操作符
	friend istream& operator>> (istream& is, Complex& c) {
		is >> c.m_r >>c.m_i;
		return is;
	}
private:
	int m_r; //实部
	int m_i; //虚部
};
int main (void)
{
	Complex c1(3,4);
	Complex c2(1,2);
	cout << c1 << endl;
	cout << c2 << endl;
	cout << "请输入一个复数: " << endl;
	cin >> c1;
	cout << c1 << endl;
	return 0;
}
